/**
 * 询价.COM v1.0.0
 * http://xun-jia.com/
 *
 * Copyright (c) 2009 
 * 四川漾天空网络科技有限公司
 * 成都市天府软件园A3栋2楼
 *
 */
package com.xunjia.util;

import java.io.Serializable;

import org.dozer.DozerBeanMapper;
import org.dozer.MappingException;

/**
 * @author Mark
 * 
 * @Email Mark_yang@xun-jia.com
 * 
 * @Date 2009-4-22 上午11:47:28
 * 
 */
public class PropertyUtil implements Serializable {

	private static final long serialVersionUID = 7084721168698269650L;

	/**
	 * 深层拷贝属性
	 * 
	 * @param source
	 * @param className
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public static Object copyProperties(Object source, Class className) {
		DozerBeanMapper mapper = new DozerBeanMapper();
		return mapper.map(source, className);
	}

	/**
	 * 深层拷贝源对象
	 * 
	 * @param source
	 * @return
	 */
	public static Object copyProperties(Object source) {
		try {
			Object re = source.getClass().newInstance();
			DozerBeanMapper mapper = new DozerBeanMapper();
			mapper.map(source, re);
			return re;
		} catch (MappingException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
		return null;
	}
}
